/* 
*@module: 
*@module: provide echarts data(water) for src/views/echart/index.vue
*@author:刘千红
*/
const theDatabase = require('../../config/db.js').theDb; //引入数据库
const radar_threshold_Schema = theDatabase.import('../../schema/reference_info.js');
const echartWaterSchema = theDatabase.import('../../schema/sample_lab_water_info.js');

const sample_water_histogram_statistic_value_Schema = theDatabase.import('../../schema/sample_water_histogram_statistic_value.js');
const sample_type2_water_statistic_value_Schema = theDatabase.import('../../schema/sample_type2_water_statistic_value.js');
class echart_Water_Model {
    /**
     *获取柱状图传入元素的数据
     *
     * @static
     * @param {*} point_num
     * @param {*} element
     * @returns
     * @memberof echart_Water_Model
     */
    static async getWaterHistogramElement(point_num, element) {
        let AllElementData
        if (element) {
            AllElementData = await sample_water_histogram_statistic_value_Schema.findAll({
                attributes: [element, 'assess_type', 'statistic_value'],
                where: {
                    point_num,
                    
                }
            })

        }
        return AllElementData
    }

    /**
     *获取water 初次调查类型下 雷达图数据各深度元素值
     *
     * @static
     * @param {*} point_num
     * @param {*} assess_type
     * @returns
     * @memberof echart_Water_Model
     */
    static async getRadartype1WaterElementDepthData(point_num, assess_type) {
        const FoldData = await echartWaterSchema.findAll({
            attributes: { exclude: ['id', 'project_num', 'sample_num', 'assess_type', 'point_num', 'count', 'attention', 'remarks', 'date'] },
            where: {
                point_num,
                assess_type
            }
        })
        return FoldData
    }

    /**
     *获取水雷达数据的国标值
     *
     * @static
     * @param {*} type
     * @returns
     * @memberof echart_Water_Model
     */
    static async getWaterRadarThresholdData(type) {
        const AllDatarData = await radar_threshold_Schema.findAll(
            {
                attributes: { exclude: ['type', 'id', 'point_num'] },
                where: {
                    type,
                }
            }
        )
        return AllDatarData
    }

    /**
     *获取详细调查类型下，雷达图的各深度元素值
     *
     * @static
     * @param {*} point_num
     * @returns
     * @memberof echart_Water_Model
     */
    static async RadarType2EachDepthValue(point_num) {
        const SelectOptions = await sample_type2_water_statistic_value_Schema.findAll({
            attributes: { exclude: ['assess_type', 'id', 'remarks'] },
            where: {
                point_num
            }
        })
        return SelectOptions
    }

    
    /**
     *获取water 3D柱状图的数据
     *
     * @static
     * @param {*} point_num
     * @param {*} assess_type
     * @param {*} element
     * @returns
     * @memberof echart_Water_Model
     */
    static async echartWaterBar3DValue(point_num, assess_type, element) {
        let AllElementData
        if (element) {
            AllElementData = await echartWaterSchema.findAll({
                attributes: ['sample_depth', 'lng', 'lat', element],
                where: {
                    point_num,
                    assess_type,
                }
            })

        }
        return AllElementData
    }
    /**
     *取出水基础表的数据
     *
     * @static
     * @param {*} assess_type
     * @returns
     * @memberof echart_Water_Model
     */
    static async getWaterElementData (assess_type){
        const AllElementData = await echartWaterSchema.findAll(
            {
                attributes: {exclude: ['id','sample_num','project_num','date','sample_depth','count','lat','lng']},
                where: {
                    assess_type
                }
            }
        )
        return AllElementData
    }

    /**
     *根据深度以及调查类型取出数据苦衷的数据
     *
     * @static
     * @param {*} sample_depth
     * @param {*} assess_type
     * @returns
     * @memberof echart_Water_Model
     */
    static async  getWaterData (sample_depth,assess_type) {
        const FoldData = await echartWaterSchema.findAll({
            attributes: {exclude: ['id','project_num','count','remarks','date']},
            where: {
                sample_depth,
                assess_type
            }
        })
        return FoldData
    }


}

module.exports = echart_Water_Model